import {GFormProps, GTable, GTableSchema} from 'geminis-react';
import React from "react";

export default () => {

    const formSchema: GFormProps = {
        schema: {
            data: {
                url: '/api/auth/registeredClient'
            }
        },
        schemaPath: '/auth-pc/schema/client/edit.json',
        onSubmitting: (value: any) => {
            value.authorizationGrantTypes =
                value.authorizationGrantTypes?.join(',');
            value.scopes = value.scopes?.join(',');
        },
        onDataLoaded: (value: any) => {
            value.authorizationGrantTypes =
                value.authorizationGrantTypes?.split(',');
            value.scopes = value.scopes?.split(',');
        }
    }

    const schema: GTableSchema = {
        headerTitle: '客户端信息',
        data: {
            url: '/api/auth/registeredClient',
        },
        action: {
            toolbar: {
                add: {
                    form: formSchema
                }
            },
            row: {
                edit: {
                    form: formSchema
                }
            }
        },
    };

    return (
        <GTable
            schema={schema}
            schemaPath="/auth-pc/schema/client/table.json"
        />
    );
};
